package me.xuym.crawler.simpleextension.processor;

import com.cbs.java.component.application.Application;
import me.xuym.crawler.Processor;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by broche on 05/08/2017.
 */
public abstract class SimpleResourceUpdateListProcessor extends Processor<List<SimpleResourceUpdateProcessorInput>, List<SimpleResourceUpdateProcessorInput>> {
    protected abstract void updateResource(Map<String, String> keys, Map<String, String> values);

    public SimpleResourceUpdateListProcessor(Application application) throws IOException {
        super(application);
    }

    @Override
    public List<SimpleResourceUpdateProcessorInput> onProcess(List<SimpleResourceUpdateProcessorInput> simpleResourceUpdateProcessorInputs) throws Exception {
        for (SimpleResourceUpdateProcessorInput input : simpleResourceUpdateProcessorInputs) {
            updateResource(input.simpleResourceUpdateProcessorKeyFields(), input.simpleResourceUpdateProcessorValueFields());
        }
        return simpleResourceUpdateProcessorInputs;
    }
}
